import java.io.*;
import java.util.*;

public class D {
	// 记忆化搜索
	public static int n;
	public static int m;
	public static int[][] a;
	public static int ret;
	public static int[] dirX;
	public static int[] dirY;
	public static boolean[][] flag;
	public static int cs = 0;
	public static boolean[][] st;
	public static int[][] vis;
	public static int num = 0;
	public static FastReader sc = new FastReader();
	public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	
	public static void main(String[] args) {
		n = sc.nextInt();
		m = sc.nextInt();
		a = new int[n + 10][m + 10];
		dirX = new int[]{-1, 0, 1, 0};
		dirY = new int[]{0, -1, 0, 1};
		flag = new boolean[n + 10][m + 10];
	    st = new boolean[n + 10][m + 10];
	    vis = new int[n + 10][m + 10];
	    
		boolean flag2 = false;
		
		for(int i = 1; i <= n; i ++ ) {
			String s = sc.next();
			for(int j = 0; j < m; j ++ ) {
				if(s.charAt(j) == '.') {
					a[i][j + 1] = 0;
					flag2 = true;
				} else {
					a[i][j + 1] = 1;
				}
			}
		}
		
		for(int i = 1; i <= n; i ++ ) {
			for(int j = 1; j <= m; j ++ ) {
				if(a[i][j] == 0 && vis[i][j] == 0) {
					cs = 0;
					num += 1;
					dfs(i, j); // 开始dfs了
					ret = Math.max(ret, cs);
				}
			}
		}
		out.print(ret + "\n");
		out.close();
	}
	
	public static void dfs(int x, int y) {
		cs += 1;
		vis[x][y] = num;
		// 比常规题 多增加了一个 返回
		for(int i = 0; i < 4; i ++ ) {
			int dx = x + dirX[i];
			int dy = y + dirY[i];
			if(a[dx][dy] == 1) { // 周围存在 磁铁 就不能走了
				return ;
			}
		}
		
		for(int i = 0; i < 4; i ++ ) {
			int dx = x + dirX[i];
			int dy = y + dirY[i];
			if(check(dx, dy)) {
				if(vis[dx][dy] == vis[x][y])continue; // 这里是比较巧妙的
				dfs(dx, dy);
			}
		}
	}
	
	public static boolean check(int x, int y) {
		return x >= 1 && x <= n && y >= 1 && y <= m && a[x][y] == 0 && st[x][y] == false;
	}
	
}



//快读的模板
class FastReader{
	StringTokenizer st;
	BufferedReader br;
	public FastReader(){
	    br=new BufferedReader(new InputStreamReader(System.in));
	}
	
	String next(){
	    while (st==null||!st.hasMoreElements()){
	        try {
	            st=new StringTokenizer(br.readLine());
	        }catch (IOException e){
	            e.printStackTrace();
	        }
	    }
	    return st.nextToken();
	}
	int nextInt() {
	    return Integer.parseInt(next());
	}
	
	long nextLong() {
	    return Long.parseLong(next());
	}
	double nextDouble() {
	    return Double.parseDouble(next());
	}
	String nextLine() {
	    String str = "";
	    try {
	        str = br.readLine();
	    } catch (IOException e) {
	        e.printStackTrace();
	    }
	    return str;
	}
}
